//
//  ControllerTool.m
//  Weibo
//
//  Created by Anasue on 9/14/15.
//  Copyright (c) 2015 Anasue. All rights reserved.
//

#import "ControllerTool.h"
#import "NewFeatureViewController.h"
#import "TabBarViewController.h"


@implementation ControllerTool

+ (void)chooseRootController
{
    NSString *versionKey = (__bridge NSString *)kCFBundleVersionKey;
    
    //取出上次存储的版本号
    NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
    NSString *lastVersion = [defaults objectForKey:versionKey];
    
    //获得当前版本号
    NSString *currentVersion = [NSBundle mainBundle].infoDictionary[versionKey];
    UIWindow *window = [UIApplication sharedApplication].keyWindow;
    if ([currentVersion isEqualToString:lastVersion]) {
        window.rootViewController = [[TabBarViewController alloc]init];
    }else{
        window.rootViewController = [[NewFeatureViewController alloc]init];
        
        [defaults setObject:currentVersion forKey:versionKey];
        [defaults synchronize];
    }
}


@end
